import time
import csv
import  keyboard

state_table = {
    (CarState.zero_forward, 'w'): lambda steer: CarController.move(accSlow, 0, steer, 1),
    (CarState.zero_forward, 's'): lambda steer: CarController.move(0, brakeNormal, steer, 1),
    (CarState.zero_forward, 'space'): lambda steer: CarController.move(0, brakeSpace, steer, 1),
    (CarState.zero_forward, 'r'): lambda steer: CarController.move(0, brakeChange, steer, 2),
    (CarState.zero_forward, 'shift+w'): lambda steer: CarController.move(accFast, 0, steer, 1),

    (CarState.zero_backward, 'e'): lambda steer: CarController.move(0, brakeChange, steer, 1),
    (CarState.zero_backward, 's'): lambda steer: CarController.move(accBack, 0, steer, 2),
    (CarState.zero_backward, 'w'): lambda steer: CarController.move(0, brakeNormal, steer, 2),
    (CarState.zero_backward, 'space'): lambda steer: CarController.move(0, brakeSpace, steer, 2),

    (CarState.zero_neutral, 'e'): lambda steer: CarController.move(0, brakeChange, steer, 1),
    (CarState.zero_neutral, 'r'): lambda steer: CarController.move(0, brakeChange, steer, 2),

    (CarState.neutral_forward, 'w'): lambda steer: CarController.move(accSlow, 0, steer, 1),
    (CarState.neutral_forward, 'shift+w'): lambda steer: CarController.move(accFast, 0, steer, 1),
    (CarState.neutral_forward, 's'): lambda steer: CarController.move(0, brakeNormal, steer, 1),
    (CarState.neutral_forward, 'space'): lambda steer: CarController.move(0, brakeSpace, steer, 1),
    (CarState.neutral_forward, 'release'): lambda steer: CarController.move(0, 0, steer, 1),

    (CarState.neutral_backward, 's'): lambda steer: CarController.move(accBack, 0, steer, 2),
    (CarState.neutral_backward, 'release'): lambda steer: CarController.move(0, 0, steer, 2),
    (CarState.neutral_backward, 'w'): lambda steer: CarController.move(0, brakeNormal, steer, 2),
    (CarState.neutral_backward, 'space'): lambda steer: CarController.move(0, brakeSpace, steer, 2),

    (CarState.forward, 'w'): lambda steer: CarController.move(accSlow, 0, steer, 1),
    (CarState.forward, 'shift+w'): lambda steer: CarController.move(accFast, 0, steer, 1),
    (CarState.forward, 's'): lambda steer: CarController.move(0, brakeNormal, steer, 1),
    (CarState.forward, 'space'): lambda steer: CarController.move(0, brakeSpace, steer, 1),
    (CarState.forward, 'release'): lambda steer: CarController.move(0, 0, steer, 1),

    (CarState.fast_forward, 'w'): lambda steer: CarController.move(accSlow, 0, steer, 1),
    (CarState.fast_forward, 'shift+w'): lambda steer: CarController.move(accFast, 0, steer, 1),
    (CarState.fast_forward, 's'): lambda steer: CarController.move(0, brakeNormal, steer, 1),
    (CarState.fast_forward, 'space'): lambda steer: CarController.move(0, brakeSpace, steer, 1),
    (CarState.fast_forward, 'release'): lambda steer: CarController.move(0, 0, steer, 1),

    (CarState.backward, 's'): lambda steer: CarController.move(accBack, 0, steer, 1),
    (CarState.backward, 'w'): lambda steer: CarController.move(0, brakeNormal, steer, 1),
    (CarState.backward, 'space'): lambda steer: CarController.move(0, brakeSpace, steer, 1),
    (CarState.backward, 'release'): lambda steer: CarController.move(0, 0, steer, 1),
}

if __name__ == '__main__':
    while True:




